//数据序列化类统一管理
import 'package:framelib/net/base_entity_factory.dart';
import 'package:module_business/module_comm/model/user_entity.dart';
import 'index_room_item_entity.dart';
import 'voice_chat_tag_entity.dart';
import 'voice_person_entity.dart';

class IndexEntityFactory with BaseEntityFactory{
  static final IndexEntityFactory _singleton = IndexEntityFactory._internal();

  static IndexEntityFactory get instance => IndexEntityFactory();


  factory IndexEntityFactory() {
    return _singleton;
  }

  IndexEntityFactory._internal(){
    //做一些操作
  }

   T generateOBJ<T>(json) {
    if(json==null)return null;
    if (1 == 0) {
      return null;
    } else if (T.toString() == "String") {
      return json as T;
    } else if (T.toString() == "VoiceChatTagEntity") {
      return VoiceChatTagEntity.fromJson(json) as T;
    }else if (T.toString() == "IndexRoomItemEntity") {
      return IndexRoomItemEntity.fromJson(json) as T;
    }else if (T.toString() == "VoicePersonEntity") {
      return VoicePersonEntity.fromJson(json) as T;
    }else if (T.toString() == "UserEntity") {
      return UserEntity.fromJson(json) as T;
    }

    else {
      return null;
    }
  }
}
